﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace MLY.LTR
{
    public partial class Messages : Bll.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
               // Master.DataBind();
            }
        }

        protected void GridView1_PreRender(object sender, EventArgs e)
        {
            if ((GridView1.Rows.Count == 0) && (Session["OrganizationId"] != null))
            {
                divEmptyGrid.Visible = true;
            }
            else
            {
                divEmptyGrid.Visible = false;
            }
        }

        protected void imgAddNewOnNoRows_Click(object sender, ImageClickEventArgs e)
        {
            Response.RedirectTo("~/LTR/EditMessage.aspx?MsgId=-1");
        }

        protected void btnDelete_OnClick(object sender, EventArgs e)
        {
            int Msgid = Int32.Parse(((ImageButton)sender).CommandArgument);
            try
            {
                Bll.clsMessage.DeleteMessageRelations(Msgid);
                if (Bll.clsMessage.DeleteMsg(Msgid))
                {
                    GridView1.DataBind();
                    Master.DataBind();
                }
            }

            catch (Exception ex)
            { throw ex; }


        }
    }
}
